class DataInfoInstance{
    private constructor(){
        this.inivit();
    }
    public url:string='';
    private static instance:DataInfoInstance=null;
    public static getInstance():DataInfoInstance{
        if (this.instance==null) this.instance=new DataInfoInstance();
        return this.instance;
    }
    public boxMaterilStandard:Laya.StandardMaterial=null;
    public boxCoinMaterialStandard:Laya.StandardMaterial=null;

    public boxMateril_arr:Array<Laya.StandardMaterial>=[];
    public BasicAllObj:Laya.Sprite3D=null;
    public objnumber:Array<number>=[0,15,08,7,10,2,19,28];
    public sphereObjNumber:Array<number>=[10,10,0,11,0,22,66];
    public coinObjNumber:Array<number>=[10,10,0,11,0,22,66];
    public starObjNumber:Array<number>=[10,10,0,11,0,22,66];
    public basicepos:Laya.Vector3=new Laya.Vector3(0.5,-0.5,-5);
    public chennum=1;
    public amendAngle:Array<number>=[60,30,-30,-60,-100,-150,-190,-230];
    public lenght_spere=15;//柱子缩放比列
    public lenght_start=15;//关卡出生位置y坐标
    public length_cyStart=16;
    public gk_objtobasicpos=1.3;//关卡产生间隔
    public sphere_objtogk=1;//关卡到球的间隔
    public basicobj:Laya.Sprite3D=null;
    public fatherobj:Laya.Sprite3D=null;
    public basiccliyder:Laya.Sprite3D=null;
    public shake_obj:Laya.MeshSprite3D=null;
    public coin_obj:Laya.Sprite3D=null;
    public star_obj:Laya.Sprite3D=null;
    public scene:Laya.Scene=null;
    public fatherSphere:Laya.Sprite3D=null;
    public distance_gk:number=3;//多长距离放一个关卡
    public create_gk_num=0;
    public camera:Laya.Camera;
    /**
     * 生命值
     */
    public txtNumber:number=4;
    public txt:Laya.Text=null;
    public txt1:Laya.Text=null;
    /**
     * 得分
     */
    public txt1Number:number=0;
    public radis:number=1;
    public play_state:number=1;//玩法123
    public play_pause:boolean=false;
    public start_state:boolean=false;
    public materialArry_sphere:Array<Laya.StandardMaterial>=[];
    public materialArry_gk:Array<Laya.StandardMaterial>=[];
    public ColorArry:Array<Laya.BlinnPhongMaterial>=[];
    public updateArry:Array<Array<number>>=[];
    public moveSpeed:number=0.05;
    public rankData:Array<any>=[];
    public rankState:number=1;//1好友排行榜 2群排行榜
    /**
     * 无敌状态
     */
    public wudi_state:boolean=false;
    public wudi_chenum:number=0;
    public coin_num:number=0;
    public dd:number=0;
    //UI 类
    public wx=null;
    public openDataContext=null;
    private rankTexture:Laya.Texture = null;
    private sprite:Laya.Sprite = new Laya.Sprite();
    private UI_arr:Array<any>=[];
    public ui_ImgBegin:Laya.Image=null;
    public ui_imgState:boolean=false;
    public crt:number=0;

    /**
     * 复活次数
     */
    public resurgence_times:number=0;
    //info
    private selfDatainfo:Array<any>=null;
    //sound
    private sound_arr:Array<string>=["res/sound/button.mp3","res/sound/ball.mp3","res/sound/fail.mp3","res/sound/pong.mp3"]
    private sound_wxVideo:Array<any>=[];
    public sound_state=1;

    //生命POS
    public txtLive1_pos:Laya.Vector2=null;
    public txtLive2_pos:Laya.Vector2=null;

    /**
     * 挑战状态
     */
    public fight_state:number=0;
    public currTZ_info:any=null;

    public coineverdy_num:number=10;
    //商城信息

    /**
     * 商品使用信息，自定义枚举
     */
    public wuUse_arr:Array<any>=[];
    public side:any=null;
    public skin:any=null;
    public btn:any=null;
    public value:any=null;
    public use:any=null;

    //share style
    private title_share:Array<string>=[];
    private pic_share:Array<string>=[];
    //ss
    public enter_onshowState:number=0;
    public ziyi_info:Array<any>=[];
    //func类
    /**
     * 振动状态
     */
    public shock_state:number=1;

    //
    /**
     * 弹出提示效果
     */
    public showTXT:Laya.Text=null;
    /**
     * 显示无敌时间
     */
    public showSpeed:Laya.Text=null;
    public showspeedImg:Laya.Image=null;
    public showicon:Laya.Text=null;
    public showiconImg:Laya.Image=null;

    private inivit():void{
        this.txtLive1_pos=new Laya.Vector2(Laya.stage.width/2-15,600);
        this.txtLive1_pos=new Laya.Vector2(Laya.stage.width/2+20,700);
        Laya.SoundManager.setSoundVolume(1);
       // Laya.SoundManager.playMusic("res/sound/bg_start.mp3");
        if(Laya.Browser.onMiniGame){
            this.wx=Laya.Browser.window.wx;
            if (this.wx!=undefined)
            this.openDataContext=this.wx.getOpenDataContext(); 
            this.wx.showShareMenu();
           
            //inivit video
            for (var i=0;i<4;i++){
                var vedeo=this.wx.createInnerAudioContext();
                vedeo.src=this.url+this.sound_arr[i];
                vedeo.autoplay=false;
                vedeo.obeyMuteSwitch=true;
                vedeo.volume=1;
                vedeo.loop=false;
                this.sound_wxVideo.push(vedeo);
            }

            let button = Laya.Browser.window.wx.createUserInfoButton({
                type: 'text',
                text: '',
                style: {
                    left: 0,
                    top: 0,
                    width: 720,
                    height: 1560,
                    lineHeight: 40,
                    alpha:0,
                    textAlign: 'center',
                    fontSize: 16,
                    borderRadius: 4
                }
            });
            button.onTap(function(res){
             //   console.log(res);
                DataInfoInstance.getInstance().ziyi_info=[res.userInfo.avatarUrl,res.userInfo.nickName];
                button.hide();
            });

            this.wx.onShow((res)=>{
                if(res.query.type=="2"){
                    this.enter_onshowState=1;
                    this.currTZ_info=res.query;
                    DataInfoInstance.getInstance().sendMessage({
                        cmd:"10",
                        key: "RankData",
                        url:res.query.url,
                        name:res.query.name,
                        value:res.query.score,
                        time:res.query.data,
                    });
                //    console.log("enter",res.query.name,res.query.score,res.query.data);
                }
            //    console.log(res,"当开6始",res.query.type);
            });
        }

        //设置声音和振动初始化
        
        if(Laya.LocalStorage.getJSON("sound_state")==null)
        {
            this.sound_state=1;
            Laya.LocalStorage.setJSON("sound_state",DataInfoInstance.getInstance().sound_state);
        }
        else{
            this.sound_state=parseInt(Laya.LocalStorage.getJSON("sound_state"));
        }
        if(Laya.LocalStorage.getJSON("shock_state")==null)
        {
            this.shock_state=1;
            Laya.LocalStorage.setJSON("shock_state",DataInfoInstance.getInstance().shock_state);
        }
        else
        {
            this.shock_state=parseInt(Laya.LocalStorage.getJSON("shock_state"));
        }


        this.coin_num=this.getCoin();

         if(Laya.LocalStorage.getJSON("shop_side")==null||
         Laya.LocalStorage.getJSON("shop_skin")==null||
         Laya.LocalStorage.getJSON("shop_btn")==null||
         Laya.LocalStorage.getJSON("shop_value")==null||
         Laya.LocalStorage.getJSON("shop_use")==null||
         Laya.LocalStorage.getJSON("shop_side")[0]==undefined||
         Laya.LocalStorage.getJSON("shop_value")[0]!=40)
         {
             Laya.LocalStorage.setJSON("shop_side",["start/shop_box_03.png","start/shop_box_01.png","start/shop_box_01.png"
             ,"start/shop_box_01.png","start/shop_box_01.png","start/shop_box_01.png"
             ,"start/shop_box_01.png","start/shop_box_01.png","start/shop_box_01.png"]);
             Laya.LocalStorage.setJSON("shop_skin",["pifu/01.png","pifu/02.png","pifu/03.png","pifu/04.png","pifu/05.png","pifu/06.png","pifu/07.png","pifu/08.png","pifu/09.png"]);
             Laya.LocalStorage.setJSON("shop_btn",["start/shop_btn_03.png","start/shop_btn_01.png","start/shop_btn_01.png",
             "start/shop_btn_01.png","start/shop_btn_01.png","start/shop_btn_01.png",
             "start/shop_btn_01.png","start/shop_btn_01.png","start/shop_btn_01.png"]);
             Laya.LocalStorage.setJSON("shop_value",[40,40,40,40,40,40,40,40,40]);
             Laya.LocalStorage.setJSON("shop_use",[UseStype.useing,UseStype.nohave,UseStype.nohave,
             UseStype.nohave,UseStype.nohave,UseStype.nohave,
             UseStype.nohave,UseStype.nohave,UseStype.nohave]);
         }

            this.side=Laya.LocalStorage.getJSON("shop_side");
            this.skin=Laya.LocalStorage.getJSON("shop_skin");
            this.btn=Laya.LocalStorage.getJSON("shop_btn");
            this.value=Laya.LocalStorage.getJSON("shop_value");
            this.use=Laya.LocalStorage.getJSON("shop_use");
            for (var i=0;i<9;i++){
            this.wuUse_arr.push([
                this.side[i],
                this.skin[i],
                this.btn[i],
                this.value[i],
                this.use[i],
            ]);
        }
        

        //inivit share
        this.title_share.push("首款3D版贪吃蛇来袭，这是你没玩过的全新版本！");
        this.title_share.push("比起下落，我更爱勇攀高峰！");
        this.title_share.push("不会转向的贪吃蛇，和咸鱼没有差别！");
        this.title_share.push("吃饱？这辈子都不可能吃饱的！休息一下接着吃");
        this.title_share.push("扶我起来！我还能再吃一百年");
        this.title_share.push("能变长的游戏，小哥哥们早就玩疯了…");
        this.title_share.push("这条蛇太魔性了，连隔壁小孩都沉迷了");
        this.title_share.push("没毛病，我就是这个群里头最铁的蛇！");
        this.title_share.push("【@所有人】头铁大比拼，快来看看你排第几？");
        this.title_share.push("确认过食量，我就是本群最能吃的蛇，不服来比呀");
        this.title_share.push("光靠吃就能变强，你真的不试试吗？");
        this.title_share.push("XXX又超越你啦，快来挑战他吧");
        this.title_share.push("给你一次战胜我的机会，不试试吗？");
        this.title_share.push("救救救命啊！一不小心掉蛇窝里了，求搭救");
        this.title_share.push("怎么就输了？一定是吃得不够多！小伙伴们求喂食！");

        this.pic_share.push("start/share01.png");
        this.pic_share.push("start/share02.png");
        this.pic_share.push("start/share03.png");
        this.pic_share.push("start/grade01.png");
        this.pic_share.push("start/grade02.png");
        this.pic_share.push("start/dare01.png");
        this.pic_share.push("start/dare02.png");
        this.pic_share.push("start/help01.png");

        //set zhuangfa
        if(Laya.Browser.onMiniGame){
             var shareInfo=this.getShareInfo(shareType.zhuangfa);
         //   console.log(shareInfo,"转发");
            this.wx.onShareAppMessage(function () {
            // 用户点击了“转发”按钮
                return {
                    title: shareInfo[0],
                    imageUrl:shareInfo[1],
                }
            })
        }

    }
    private shareinfo:Array<any>=[];
    public getShareInfo(type:shareType):Array<any>{

        this.shareinfo=[];
        let title:number=0;
        let picNum:number=0;
        if(type==shareType.recommend||type==shareType.share||type==shareType.zhuangfa){
            while(true){
                title=Math.floor(Math.random()*10);
                if(title<7) break;
            }
            while(true){
                picNum=Math.floor(Math.random()*10);
                if(picNum<3) break;
            }
        }
        else if(type==shareType.resultsShare||type==shareType.groupRank){
             while(true){
                title=Math.floor(Math.random()*10);
                if(title<10&&title>=7) break;
            }
            while(true){
                picNum=Math.floor(Math.random()*10);
                if(picNum<5&&picNum>=3) break;
            }
        }
        else if(type==shareType.pk){
             while(true){
                title=Math.floor(Math.random()*10)+10;
                if(title<13&&title>=10) break;
            }
            while(true){
                picNum=Math.floor(Math.random()*10);
                if(picNum<7&&picNum>=5) break;
            }
        }
        else if(type==shareType.help||type==shareType.resurgence)
        {
             while(true){
                title=Math.floor(Math.random()*10)+10;
                if(title<15&&title>=13) break;
            }
            picNum=7;
        }
        this.shareinfo=[this.title_share[title],this.pic_share[picNum]];
        return this.shareinfo
    }

    public showEffect(message:string):void{
        
        
        
        if(this.showTXT.text=='')
        {
            Laya.timer.once(700, this, function () {
                DataInfoInstance.getInstance().showTXT.changeText('');
            });
        }
        this.showTXT.changeText(message);
        
    }
    private wunum:number=0;
    private wnstring:string='';
    public showspeedTxt():void{
        this.wunum=30-this.wudi_chenum;
        if(this.wunum<=0){
            this.wnstring='';
            this.showspeedImg.visible=false;
        }
        else{
            this.wnstring=this.wunum.toString();
            this.showspeedImg.visible=true;
        }
        this.showSpeed.changeText(this.wnstring);
    }
    public showiconTxt():void{
        this.showiconImg.visible=true;
        this.showicon.changeText(this.coin_num.toString());
    }
    public inivitUIManage():void{
        if(this.UI_arr.length==0)
        {

        }
      //  DataInfoInstance.getInstance().ui_start.ivivitSoundAndShock();
    }
    public PlaySoundOnce(name:SoundName){
        if (this.sound_state!=1) return;
        if(Laya.Browser.onMiniGame){
            for (var i=0;i<this.sound_wxVideo.length;i++){
                this.sound_wxVideo[i].stop();
            }
            this.sound_wxVideo[name-1].play();
        }
        
       // Laya.SoundManager.playSound(this.sound_arr[name-1],1);
    }
    public setShoot():void{
        if(DataInfoInstance.getInstance().shock_state==1&&Laya.Browser.onMiniGame){
            Laya.Browser.window.wx.vibrateShort();
        }
    }
    public UIManage(viewID:uiView,only:boolean):void{
        if (only)
        {
            if(viewID!=uiView.all)
            {
                this.UI_arr[viewID].popup(true);
            }
            for (var i=0;i<this.UI_arr.length;i++)
            {
                if (i!=viewID)
                {
                 this.UI_arr[i].close(null,false);
                }
            }            
        }
        else{
            if(viewID!=uiView.all)
            {
                this.UI_arr[viewID].visible=true;
                this.UI_arr[viewID].popup(false);
            }
        }
    }
    public sendMessage(message):void{
      //  GameBootstrap.getWXIntance().wxPostMessage(message,null,this.getMessage);
    }

    public setCoin(val:number,isadd:boolean){
        if(isadd)
        {
            var a=val+this.getCoin();
            this.coin_num=a;
            Laya.LocalStorage.setItem("coin",a.toString())
        }
        else
        {
            this.coin_num=val;
            Laya.LocalStorage.setItem("coin",val.toString())
        }
        
    }
    public getCoin():number{
        var a:number=parseInt(Laya.LocalStorage.getItem("coin"));
        if(!a)
        {
            a=0;
            this.coin_num=0;
            Laya.LocalStorage.setItem("coin","0")
        }
        return a;
    }
    //获取信息
    public getMessage=function(message:any):void{

    }
    public setSpeed():void{
        //if (this.txt1Number%5==0 && this.txt1Number>0){
         //   this.moveSpeed=4000-Math.floor(this.txt1Number/5)*10;
        //}
       // else if(this.txt1Number%5==0){
            this.moveSpeed=3000;
     //   }
        if(this.wudi_state) this.moveSpeed=this.moveSpeed-this.moveSpeed*0.4;
        this.moveSpeed=this.moveSpeed<1000?1000:this.moveSpeed;
        //console.log(this.moveSpeed,"设置速度",this.wudi_state,this.txt1Number);
     //   this.play.setDistance(this.moveSpeed);
    }

    //关卡数据
    private gknum:Array<number>=[];
    private sphere:Array<number>=[];
    private time_1:number=0;
    private time_2:number=0;
    public gk_sphereData(num:number):void{
       // console.log("enter1");
        this.gknum=[];
        this.sphere=[];
        let blood=0;
        let sphnum=0;
        if (num-1==0||(num-1)%15==0){
         //   console.log("enter2");
            if (num<10)
            {
              while(true)
              {
                  blood=Math.floor(Math.random()*10);
                  
                  if (blood>0&&blood<5&&this.gknum.length<8)
                  {
                      this.gknum.push(blood);
                  }
                  else if(this.gknum.length>=8) break ;
              }  
            }
            else
            {
                //等策划内容
                this.gknum.push(this.txtNumber+Math.floor(this.txtNumber*Math.random()));
                this.gknum.push(this.txtNumber+Math.floor(this.txtNumber*Math.random()));
             //   console.log("eeenter2ss1");
                while(true)
                {
                    var cugknum=Math.floor(Math.random()*10);
                    if (cugknum<6&&cugknum>0)
                    {
                         this.gknum.push(this.txtNumber+cugknum);
                         break;
                    }
                }
           //    console.log("eeenter2ss2");
                while(true)
                {
                    var cugknum=Math.floor(Math.random()*10);
                    if (cugknum<6&&cugknum>0)
                    {
                         this.gknum.push(this.txtNumber+cugknum);
                         break;
                    }
                }
                this.gknum.push(this.txtNumber);
                this.gknum.push(this.txtNumber);
            //    console.log("eeenter2ss3");
                let cur1:number=0;
                while(true){
                    var cugknum=Math.floor(this.txtNumber*Math.random());
                    cur1++;
                    if(cur1>10)
                    {
                        cugknum=Math.floor(this.txtNumber*0.5);
                    }
                //    console.log(cugknum,this.txtNumber);
                    if(cugknum<=this.txtNumber*0.5&&cugknum>=this.txtNumber*0.3)
                    {
                        this.gknum.push(cugknum);
                        break;
                    }

                    if(this.txtNumber==1)
                    {
                        this.gknum.push(1);
                        break;
                    }
                }
             //   console.log("eeenter2ss4");
                 let cur2:number=0;
                while(true){
                    var cugknum=Math.floor(this.txtNumber*Math.random());
                    cur2++;
                    if(cur2>10)
                    {
                        cugknum=Math.floor(this.txtNumber*0.5);
                    }
                    if(cugknum<=this.txtNumber*0.5&&cugknum>=this.txtNumber*0.3)
                    {
                        this.gknum.push(cugknum);
                        break;
                    }
                    if(this.txtNumber==1)
                    {
                        this.gknum.push(1);
                        break;
                    }
                }

            }
        }
        else if ((num-2)%15==0){
           // console.log("enter3");
            this.gknum=[];
            this.sphere=[];
        }
        else if ((num-3)%15==0){
           // console.log("enter4");
            this.gknum=[];
            while(true)
              {
                  blood=Math.floor(Math.random()*10);
                  if (blood>0&&blood<6&&this.sphere.length<2)
                  {
                      this.sphere.push(blood);
                  }
                  else if(this.sphere.length>=2) break ;
              }
        }
        else if ((num-4)%15==0){
         //   console.log("enter5");
            let cugknum=0;
            while(true)
            {
                sphnum=Math.floor(Math.random()*10);
                if (sphnum>0&&sphnum<6)
                {
                    this.sphere.push(sphnum);
                    break;
                }
            }
            while(true)
            {
                cugknum=Math.floor(Math.random()*10);
                if (cugknum<3&&cugknum>0)break;
            }
            while(true)
            {
                blood=Math.floor(Math.random()*10);
                if (blood>0&&blood<6&&this.gknum.length<cugknum)
                {
                    this.gknum.push(blood);
                }
                else if(this.gknum.length>=cugknum){ break} ;
            }  

            
        }
        else if ((num-5)%15==0){
         //   console.log("enter6");
             this.gknum=[];
            let cugknum=0;
            let as=false;
             while(true)
            {
                cugknum=Math.floor(Math.random()*10);
                if (cugknum<3&&cugknum>0)
                {
                    while(true)
                    {
                        blood=Math.floor(Math.random()*10);
                        if (blood>0&&blood<6&&this.sphere.length<cugknum)
                        {
                            this.sphere.push(blood);
                        }
                        else if(this.sphere.length>=cugknum){ as=true; break} ;
                    }  
                    if (as)break;
                }
            }
        }
        else if ((num-6)%15==0){
          //  console.log("enter7");
             this.gknum=[];

            while(true)
            {
                blood=Math.floor(Math.random()*10);
                if (blood>0&&blood<6&&this.sphere.length<2)
                {
                    this.sphere.push(blood);
                }
                else if(this.sphere.length>=2){  break} ;
            }  
                
        }
        else if ((num-7)%15==0){
          // console.log("enter8");
            let cugknum=0;
            let as=false;
            while(true)
            {
                cugknum=Math.floor(Math.random()*10);
                if (cugknum<7&&cugknum>0)
                {
                    while(true)
                    {
                        blood=Math.floor(Math.random()*10);
                        if (blood>0&&blood<6&&this.gknum.length<cugknum)
                        {
                            this.gknum.push(blood);
                        }
                        else if(this.gknum.length>=cugknum){ as=true; break} ;
                    }  
                    if (as)break;
                }
            }

             while(true)
            {
                sphnum=Math.floor(Math.random()*10);
                if (sphnum>0&&sphnum<6)
                {
                    this.sphere.push(sphnum);
                    break;
                }
            }
        }
        else if ((num-8)%15==0){
           // console.log("enter9");
            this.gknum=[];
            while(true)
            {
                sphnum=Math.floor(Math.random()*10);
                if (sphnum>0&&sphnum<6)
                {
                    this.sphere.push(sphnum);
                    break;
                }
            }
        }
        else if ((num-9)%15==0){
           // console.log("enter10");
            this.gknum=[];
            while(true)
            {
                sphnum=Math.floor(Math.random()*10);
                if (sphnum>0&&sphnum<6)
                {
                    this.sphere.push(sphnum);
                    if (this.sphere.length>=2)break;
                }
            }
        }
        else if ((num-10)%15==0){
          //  console.log("enter11");
            this.gknum=[];
            while(true)
            {
                sphnum=Math.floor(Math.random()*10);
                if (sphnum>0&&sphnum<6)
                {
                    this.sphere.push(sphnum);
                    if (this.sphere.length>=2)break;
                }
            }
        }
        else if((num-11)%15==0){
         //   console.log("enter12");
            let cugknum=0;
            let as=false;
            while(true)
            {
                cugknum=Math.floor(Math.random()*10);
                if (cugknum<4&&cugknum>0)
                {
                    while(true)
                    {   var sd=Math.floor(Math.random()*10);
                        if (sd>=5 &&this.gknum.length<cugknum)
                        {this.gknum.push(this.txtNumber+5);}
                        else if (this.gknum.length<cugknum)
                        {
                            blood=Math.floor(this.txtNumber*Math.random());
                            this.gknum.push(blood);
                        }
                        else if(this.gknum.length>=cugknum){ as=true; break} ;
                    } 
                    if (as)break;
                }
            }

             while(true)
            {
                sphnum=Math.floor(Math.random()*10);
                if (sphnum>0&&sphnum<6)
                {
                    this.sphere.push(sphnum);
                    break;
                }
            }
        }
        else if((num-12)%15==0){
           // console.log("enter13");
            this.gknum=[];
            while(true)
            {
                sphnum=Math.floor(Math.random()*10);
                if (sphnum>0&&sphnum<6)
                {
                    this.sphere.push(sphnum);
                    if (this.sphere.length>=2)break;
                }
            }
        }
        else if((num-13)%15==0){
          //  console.log("enter14");
            this.gknum=[];
            this.sphere=[];
        }
        else if((num-14)%15==0){
          //  console.log("enter14");
            let cugknum=0;
            let as=false;
            while(true)
            {
                cugknum=Math.floor(Math.random()*10);
                if (cugknum<4&&cugknum>0)
                {
                    while(true)
                    {   var sd=Math.floor(Math.random()*10);
                        if (sd>=5 &&this.gknum.length<cugknum)
                        {this.gknum.push(this.txtNumber+5);}
                        else if (this.gknum.length<cugknum)
                        {
                            blood=this.txtNumber+Math.floor(this.txtNumber*Math.random());
                            this.gknum.push(blood);
                        }
                        else if(this.gknum.length>=cugknum){ as=true; break} ;
                    } 
                    if (as)break;
                }
            }

             while(true)
            {
                sphnum=Math.floor(Math.random()*10);
                if (sphnum>0&&sphnum<6)
                {
                    this.sphere.push(sphnum);
                    break;
                }
            }
        }
        else if((num-15)%15==0){
            this.gknum=[];
            this.sphere=[];
        }

        //打乱数组，并赋值
        //gk
        //console.log("enter16");
        this.objnumber=[];
        if(this.gknum.length==0)
        {
            this.objnumber=[0,0,0,0,0,0,0,0];
        }
        else if(this.gknum.length<8)
        {
            this.objnumber=[0,0,0,0,0,0,0,0];
            for (var i=0;i<this.gknum.length;i++)
            {
                var s=0;
                while(true)
                {
                    s=Math.floor(Math.random()*10);
                    if (s>-1&&s<8&&this.objnumber[s]==0)
                    {this.objnumber[s]=this.gknum[i]; break;}
                }
            }
        }
        else this.objnumber=this.gknum;

        //sphere
        this.sphereObjNumber=[];
       //  console.log(this.chennum,"sphere"+this.sphere.length+":"+this.sphere,"gk",this.gknum.length,this.gknum);
        // console.log("gk"+gknum.length+":"+gknum);
       // console.log("enter17");
        if(this.sphere.length==0)
        {
            this.sphereObjNumber=[0,0,0,0,0,0,0,0];
        }
        else if(this.sphere.length<8)
        {
            this.sphereObjNumber=[0,0,0,0,0,0,0,0];
            for (var i=0;i<this.sphere.length;i++)
            {
                var s=0;
                while(true)
                {
                    s=Math.floor(Math.random()*10);
                    if (s>-1&&s<8&&this.sphereObjNumber[s]==0)
                    {
                        this.sphereObjNumber[s]=this.sphere[i];
                         break;}
                }
            }
        }
        else this.sphereObjNumber=this.sphere;
        //test
     //   this.objnumber=[0,0,0,0,0,0,0,0];
      //  this.sphereObjNumber=[1,2,3,4,5,6,7,8];

        //设置coin 和无敌道具
     //   console.log("enter18");
        this.coinObjNumber=[0,0,0,0,0,0,0,0];
        this.starObjNumber=[0,0,0,0,0,0,0,0];
        //15 层 有三个金币 两个加速
        if(num%15==0)
        {
            this.chen_coin_num=0;
            this.chen_speed_num=0;
        }
        if(this.chen_coin_num<3||this.chen_speed_num<2)
        {
            var index:number=-1;
            this.coinarr_arr=[];
            for (var i=0;i<this.sphereObjNumber.length;i++ ){
                if(this.sphereObjNumber[i]==0){
                    index=i;
                    this.coinarr_arr.push(i);
                }
            }
            if(index!=-1){
                while(true)
                {
                    index=Math.floor(Math.random()*10);
                    if(index<=this.coinarr_arr.length-1||index>=0)
                    {
                        index=this.coinarr_arr[index];
                        break;
                    }
                   
                }
                var as=Math.floor(Math.random()*10);
                if(as<=3||as>=0){
                    as=Math.floor(Math.random()*10);
                    if(as>=5)
                    {
                        this.starObjNumber[index]=1;
                        this.chen_speed_num++;
                    }
                    else
                    {
                        this.coinObjNumber[index]=1;
                        this.chen_coin_num++;
                    }
                }
            }
        }


        // if(num%7==0){
        //     var index:number=-1;
        //     this.coinarr_arr=[];
        //     for (var i=0;i<this.sphereObjNumber.length;i++ ){
        //         if(this.sphereObjNumber[i]==0){
        //             index=i;
        //             this.coinarr_arr.push(i);
        //         }
        //     }
        //     if(index!=-1){
        //         while(true)
        //         {
        //             index=Math.floor(Math.random()*10);
        //             if(index<=this.coinarr_arr.length-1||index>=0)
        //             {
        //                 index=this.coinarr_arr[index];
        //                 break;
        //             }
                   
        //         }

        //         if(this.coinstate>=0){
        //             this.coinstate=-7;
        //             this.coinObjNumber[index]=1;
        //         }
        //         else{
        //             this.coinstate++;
        //             this.starObjNumber[index]=1;
                    
        //         }
        //     }
        // }

       // console.log("enter1out",this.objnumber,this.sphereObjNumber);
    }

    private coinarr_arr:Array<number>=[];
    private coinstate:number=0;
    private chen_coin_num:number=0;
    private chen_speed_num:number=0;
}

enum uiView{
    Start=0,
    Rank=1,
    End=2,
    Result=3,
    shlider=4,
    welcome=5,
    shope=6,
    fighting=7,
    all=8,

}
enum SoundName{
    button=1,
    ball=2,
    fail=3,
    pong=4
}
enum BasicStype{
    gk=1,
    sp=2,
    coin=3,
    speed=4,
}
/**
     * 挑战类型
     */
enum TZType{
    /**
     * 失败
     */
    fail=1,
    /**
     * 成功
     */
    success=2,
    /**
     * 挑战者
     */
    manage=3,
}
/**
 * 使用状态
 */
enum UseStype{
    /**
     * 正在使用
     */
    useing=1,
    /**
     * 没有使用
     */
    nouse=2,
    /**
     * 没有拥有
     */
    nohave=3
}

/**
     * 分享类型
     */
enum shareType{
    /**
     * 推荐
     */
    recommend=1,
    /**
     * 分享
     */
    share=2,
    /**
     * 转发
     */
    zhuangfa=3,
    /**
     * 战绩炫耀
     */
    resultsShare=4,
    /**
     * 群排行榜
     */
    groupRank=5,
    /**
     * 挑战
     */
    pk,
    /**
     * 复活
     */
    resurgence,
    /**
     * 帮助
     */
    help,
}